package com.yuanfeng.payment.controller;

import com.yuanfeng.commoms.util.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 微信支付
 *
 * @author ilove
 */
@CrossOrigin
@RestController
@RequestMapping("pay/WXPay")
public class WXPayController extends BaseController {


	/**
	 * 微信支付回调
	 *
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/notifyWeiXinPay")
	public String notifyWeiXinPay(HttpServletRequest request, HttpServletResponse response) {
		String msg = weChatPayServices.notifyWeiXinPay(request, response);
		return msg;
	}


	/**
	 * 获取微信网页code链接
	 *
	 */
	@PostMapping("/getCode")
	public Map<String, Object> getCode(@RequestBody Map<String, String> paraMap) {
		Map<String, Object> result = weChatPayServices.getCode(paraMap);
		return result;
	}

	/**
	 * 获取微信网页OpenId
	 *
	 */
	@PostMapping("/getOpenId")
	public Map<String, Object> getOpenId(@RequestBody Map<String, String> paraMap) {
		Map<String, Object> result = weChatPayServices.getOpenId(paraMap);
		return result;
	}


	/**
	 * plus 微信支付回调
	 *
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/plusNotifyWeiXinPay")
	public String plusNotifyWeiXinPay(HttpServletRequest request, HttpServletResponse response) {
		String msg = weChatPayServices.plusNotifyWeiXinPay(request, response);
		return msg;
	}

	/**
	 * 轮询微信支付后状态
	 *
	 * @param map
	 * @return
	 */
	@PostMapping("/queryWxPayStatus")
	public ResponseResult queryWxPayStatus(@RequestBody Map<Object, Object> map) {
		return weChatPayServices.queryWxPayStatus(map);
	}

	/**
	 * 轮询plus 会员微信支付后状态
	 *
	 * @param map
	 * @return
	 */
	@PostMapping("/queryWxPayplus")
	public ResponseResult queryWxPayplus(@RequestBody Map<Object, Object> map) {
		return weChatPayServices.queryWxPayplus(map);
	}
}
